﻿Imports MySql.Data.MySqlClient
Imports System.Data.OleDb
Imports System.Data.Odbc
Imports System.Drawing
Imports System.Windows.Forms

Public Class frmpackage3
    Dim check_group As String = ""
    Dim check_sub As Integer = 0
    Public Shared name_lastname As String = " "
    Public Shared doctor_name As String = " "
    Dim count_group As Integer = 1
    Dim check_form As String = "0"
    Dim count_result As String
    Public Shared result_all As String = " "
    Public Shared address As String = " "
    Public Shared export_date As String = " "
    Public Shared tellephone As String = " "
    Public Shared under As String = " "
    Public Shared pulse_rate As String = " "
    Dim position_user As String
    Public selectedEmployee As String
    Dim idcontainer As String
    Dim mysqlpass As String
    Dim ipconnect As String
    Dim usernamedb As String
    Dim dbname As String
    Dim export_id As String
    Dim id_hn As String
    Public Shared urine_other As String = " "
    Public Shared result_phy As String = " "
    Public Shared result_hematology As String = " "
    Public Shared result_urine As String = " "
    Public Shared result_physical As String = " "
    Public Shared result_xray As String = " "
    Public Shared result_ultrasound As String = " "
    Public Shared result_ekg As String = " "
    Public Shared result_bloodchem As String = " "
    Public Shared result_bun As String = " "
    Public Shared result_creatinine As String = " "
    Public Shared result_uricacid As String = " "
    Public Shared result_cholesterol As String = " "
    Public Shared result_triglyceride As String = " "
    Public Shared result_hdl As String = " "
    Public Shared result_ldl As String = " "
    Public Shared result_sgot As String = " "
    Public Shared result_sgpt As String = " "
    Public Shared result_alkaline As String = " "
    Public Shared result_afp As String = " "
    Public Shared result_pfp As String = " "
    Public Shared result_fbs As String = " "
    Public Shared phy_height As String = " "
    Public Shared phy_weight As String = " "
    Public Shared phy_bmi As String = " "
    Public Shared phy_bloodpressure As String = " "
    Public Shared phy_pulse As String = " "
    Public Shared phy_eye_left As String = " "
    Public Shared phy_eye_right As String = " "
    Public Shared phy_dental As String = " "
    Public Shared tab2_redcell As String = " "
    Public Shared red_homology As String = " "
    Dim address_text As String

    Dim mysql As MySqlConnection
    Public Sub New(ByRef mysql_pass As String, ByRef ip_connect As String, ByRef user_namedb As String, ByRef db_name As String, ByRef idexport As String, ByRef idhn As String)
        InitializeComponent()
        mysqlpass = mysql_pass

        selectedEmployee = ""
        ipconnect = ip_connect
        usernamedb = user_namedb
        dbname = db_name
        export_id = idhn
        id_hn = idexport
    End Sub
    Private Sub frmpackage3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim string_redcell As String = ""
        clear()

        count_result = 1
        mysql = New MySqlConnection
        mysql.ConnectionString = "server=" + ipconnect + ";user id=" + usernamedb + ";password=" + mysqlpass + ";database=" + dbname + ";Character Set =utf8;"
        Try
            mysql.Open()
            '    MsgBox("CONNECTED TO DATABASE")
        Catch ex As Exception
            MsgBox("Can't Connect to database" + ex.Message)

            Me.Close()
        End Try




        If id_hn <> "0" And export_id <> "0" Then
            Dim mySqlCommand As New MySqlCommand
            Dim mySqlAdaptor As New MySqlDataAdapter
            Dim mySqlReader As MySqlDataReader
            Dim amp As String
            Dim prv As String
            Dim tmp As String
            Dim zipcode As String


            Dim MyODBCConnection As New OdbcConnection("dsn=RYHPFV5; Userid=mse;Password=m0116;")     'Open the connection
            Try
                MyODBCConnection.Open()
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try

            ' Dim selectCMD As OdbcCommand = New OdbcCommand("SELECT * FROM REGMASV5PF WHERE RMSHNNO='7708' and RMSHNYR = '56'")
            Dim selectCMD As OdbcCommand = New OdbcCommand("SELECT * FROM REGDETV5PF WHERE RDTHN = '" & id_hn & "'")

            selectCMD.Connection = MyODBCConnection


            Try
                'Set the mouse to show a Wait cursor
                Dim dr As OdbcDataReader = selectCMD.ExecuteReader
                'start the Read loop
                While dr.Read
                    'Note: the numbers in double quotes represent the column number from the AS400 database
                    'Add the data to the list view
                    address_text = dr.GetString(2).Trim

                    txt_tell.Text = dr.GetString(9).Trim

                    amp = dr.GetString(4)
                    prv = dr.GetString(3)
                    tmp = dr.GetString(5)
                    zipcode = dr.GetString(6)
                    'End the loop
                End While
                'Reset the cursor


            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try


            MyODBCConnection.Close()

            If MyODBCConnection.State = ConnectionState.Closed Then
                MyODBCConnection.Open()
            End If

            selectCMD = New OdbcCommand("SELECT TPVPRVNAM,TMPAMPNAM,TBNTBNNAM FROM TABPRVV5PF,TABAMPV5PF,TABTBNV5PF WHERE TABPRVV5PF.TPVPRVCOD = TABAMPV5PF.TMPPRVCOD AND TABAMPV5PF.TMPAMPCOD = TABTBNV5PF.TBNAMPCOD AND TABAMPV5PF.TMPPRVCOD = TABTBNV5PF.TBNPRVCOD AND (TABAMPV5PF.TMPPRVCOD = '" & prv & "') AND (TABTBNV5PF.TBNTBNCOD = '" & tmp & "') AND (TABAMPV5PF.TMPAMPCOD = '" & amp & "')")

            selectCMD.Connection = MyODBCConnection




            Try
                'Set the mouse to show a Wait cursor
                Dim dr As OdbcDataReader = selectCMD.ExecuteReader
                'start the Read loop
                While dr.Read
                    If dr.GetString(2) IsNot DBNull.Value Then
                        address_text = address_text + " ตำบล " + dr.GetString(2).Trim

                    End If
                    If dr.GetString(1) IsNot DBNull.Value Then
                        MsgBox("tet")
                        address_text = address_text + " อำเภอ " + dr.GetString(1).Trim

                    End If
                    If dr.GetString(0) IsNot DBNull.Value Then
                        address_text = address_text + " จังหวัด " + dr.GetString(0).Trim

                    End If

                    address_text = address_text + " " + zipcode
                End While

            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
            txt_address.Text = address_text
            MyODBCConnection.Close()



            If mysql.State = ConnectionState.Closed Then
                mysql.Open()
            End If
            mySqlCommand.CommandText = "Select * from checkup_export where hn like '" + id_hn + "' and checkup_export_id like '" + export_id + "' ;"
            mySqlCommand.Connection = mysql
            mySqlAdaptor.SelectCommand = mySqlCommand

            Try
                mySqlReader = mySqlCommand.ExecuteReader

                While mySqlReader.Read()
                    txt_name.Text = "คุณ " + mySqlReader("f_name") + " " + mySqlReader("l_name")
                    If mySqlReader("sex_code") = "3" Then
                        txt_sex.Text = "หญิง"
                    Else
                        txt_sex.Text = "ชาย"
                    End If
                    txt_age.Text = mySqlReader("age_y")
                    txt_date.Text = mySqlReader("export_date")

                    'tab2

                    If mySqlReader("R17") Is "Normal" Then

                        tab2_txt_redcell.Text = "อยู่ในเกณฑ์ปกติ(Normal Value)"

                    ElseIf mySqlReader("R17") Is DBNull.Value Then

                        If mySqlReader("R18") Is DBNull.Value Then

                        Else
                            string_redcell = string_redcell + "Hypochromia-few,"
                        End If

                        If mySqlReader("R19") Is DBNull.Value Then
                        Else
                            string_redcell = string_redcell + "Anisocytosis-few,"
                        End If
                        If mySqlReader("R20") Is DBNull.Value Then
                        Else
                            string_redcell = string_redcell + "Microcyte-few,"
                        End If
                        If mySqlReader("R21") Is DBNull.Value Then
                        Else
                            string_redcell = string_redcell + "Macrocyte-few,"
                        End If
                        If mySqlReader("R22") Is DBNull.Value Then
                        Else
                            string_redcell = string_redcell + "Poikilocytosis-few,"
                        End If
                        If mySqlReader("R23") Is DBNull.Value Then
                        Else
                            string_redcell = string_redcell + "Ovalocyte-few,"
                        End If

                        If mySqlReader("R24") Is DBNull.Value Then
                        Else
                            string_redcell = string_redcell + "Schistocyte-few,"
                        End If
                        If mySqlReader("R25") Is DBNull.Value Then
                        Else
                            string_redcell = string_redcell + "Burr-few,"
                        End If
                        If mySqlReader("R26") Is DBNull.Value Then
                        Else
                            string_redcell = string_redcell + "Target Cell-few,"
                        End If
                        If mySqlReader("R27") Is DBNull.Value Then
                        Else
                            string_redcell = string_redcell + "Polychromasia-few,"
                        End If
                        If mySqlReader("R28") Is DBNull.Value Then
                        Else
                            string_redcell = string_redcell + "Basophilic-few"
                        End If


                        tab2_txt_redcell.Text = string_redcell
                    End If

                    If mySqlReader("R79") Is DBNull.Value Then
                        tab2_txt_groupblood.BackColor = Color.DarkSeaGreen
                    Else
                        tab2_txt_groupblood.Text = mySqlReader("R79")

                    End If
                    If mySqlReader("R80") Is DBNull.Value Then
                        tab2_txt_rh.BackColor = Color.DarkSeaGreen
                    Else
                        tab2_txt_rh.Text = mySqlReader("R80")

                    End If

                    If mySqlReader("R3") Is DBNull.Value Then
                        tab2_txt_hb.BackColor = Color.DarkSeaGreen
                    Else
                        tab2_txt_hb.Text = mySqlReader("R3")

                    End If
                    If mySqlReader("R4") Is DBNull.Value Then
                        tab2_txt_hct.BackColor = Color.DarkSeaGreen
                    Else

                        tab2_txt_hct.Text = mySqlReader("R4")

                    End If
                    If mySqlReader("R1") Is DBNull.Value Then
                        tab2_txt_wbc.BackColor = Color.DarkSeaGreen
                    Else

                        tab2_txt_wbc.Text = mySqlReader("R1")
                    End If
                    If mySqlReader("R15") Is DBNull.Value Then
                        tab2_txt_atypical.BackColor = Color.DarkSeaGreen
                    Else
                        tab2_txt_atypical.Text = mySqlReader("R15")

                    End If

                    If mySqlReader("R14") Is DBNull.Value Then


                        tab2_txt_bashophils.BackColor = Color.DarkSeaGreen
                    Else
                        tab2_txt_bashophils.Text = mySqlReader("R14")
                    End If

                    If mySqlReader("R13") Is DBNull.Value Then
                        tab2_txt_eosinophils.BackColor = Color.DarkSeaGreen
                    Else

                        tab2_txt_eosinophils.Text = mySqlReader("R13")
                    End If

                    If mySqlReader("R11") Is DBNull.Value Then
                        tab2_txt_lymphocytes.BackColor = Color.DarkSeaGreen
                    Else
                        tab2_txt_lymphocytes.Text = mySqlReader("R11")
                    End If

                    If mySqlReader("R12") Is DBNull.Value Then
                        tab2_txt_monocytes.BackColor = Color.DarkSeaGreen
                    Else
                        tab2_txt_monocytes.Text = mySqlReader("R12")
                    End If

                    If mySqlReader("R10") Is DBNull.Value Then
                        tab2_txt_neutrophils.BackColor = Color.DarkSeaGreen
                    Else
                        tab2_txt_neutrophils.Text = mySqlReader("R12")
                    End If


                    If mySqlReader("R8") Is DBNull.Value Then
                        tab2_txt_plate.BackColor = Color.DarkSeaGreen
                    Else
                        tab2_txt_plate.Text = mySqlReader("R8")
                    End If


                    ' tab3


                    If mySqlReader("R32") Is DBNull.Value Then
                        tab3_txt_color.BackColor = Color.DarkSeaGreen
                    Else
                        tab3_txt_color.Text = mySqlReader("R32")
                    End If


                    If mySqlReader("R33") Is DBNull.Value Then
                        tab3_txt_appearance.BackColor = Color.DarkSeaGreen
                    Else
                        tab3_txt_appearance.Text = mySqlReader("R33")
                    End If

                    If mySqlReader("R34") Is DBNull.Value Then
                        tab3_txt_spgr.BackColor = Color.DarkSeaGreen
                    Else
                        tab3_txt_spgr.Text = mySqlReader("R34")
                    End If
                    If mySqlReader("R36") Is DBNull.Value Then
                        tab3_txt_albumin.BackColor = Color.DarkSeaGreen
                    Else
                        tab3_txt_albumin.Text = mySqlReader("R36")
                    End If

                    If mySqlReader("R37") Is DBNull.Value Then
                        tab3_txt_glucose.BackColor = Color.DarkSeaGreen
                    Else
                        tab3_txt_glucose.Text = mySqlReader("R37")
                    End If


                    If mySqlReader("R41") Is DBNull.Value Then
                        tab3_txt_blood.BackColor = Color.DarkSeaGreen
                    Else
                        tab3_txt_blood.Text = mySqlReader("R41")
                    End If

                    If mySqlReader("R35") Is DBNull.Value Then
                        tab3_txt_ph.BackColor = Color.DarkSeaGreen
                    Else
                        tab3_txt_ph.Text = mySqlReader("R35")
                    End If


                    If mySqlReader("R44") Is DBNull.Value Then
                        tab3_txt_rbc.BackColor = Color.DarkSeaGreen
                    Else
                        tab3_txt_rbc.Text = mySqlReader("R44")
                    End If


                    If mySqlReader("R45") Is DBNull.Value Then
                        tab3_txt_wbc.BackColor = Color.DarkSeaGreen
                    Else
                        tab3_txt_wbc.Text = mySqlReader("R45")
                    End If


                    If mySqlReader("R46") Is DBNull.Value Then
                        tab3_txt_epi.BackColor = Color.DarkSeaGreen
                    Else
                        tab3_txt_epi.Text = mySqlReader("R46")
                    End If


                    'tab4

                    If mySqlReader("R54") Is DBNull.Value Then
                        tab4_txt_fbs.BackColor = Color.DarkSeaGreen
                    Else
                        tab4_txt_fbs.Text = mySqlReader("R54")

                        Dim int_fbs As Integer
                        int_fbs = Integer.Parse(tab4_txt_fbs.Text)
                        tab4_txt_fbs.Text = int_fbs

                        If int_fbs >= 70 And int_fbs <= 110 Then
                            tab4_result_fbs.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                        ElseIf int_fbs > 111 And int_fbs <= 125 Then
                            If check_sub = 0 Then
                                tab4_result_fbs.Text = "การควบคุมน้ำตาลบกพร่อง คำแนะนำ ควรลดอาหาร แป้ง รับประทานผัก ผลไม้ มากขึ้น และตรวจซ้ำ 1 เดือน"
                            ElseIf check_sub = 1 Then
                                tab4_result_fbs.Text = "Impaired glucose control : Reduce sweet foods,flour.Eat more fruit and vegetables and repeat blood test in 1 month."
                            End If

                        ElseIf int_fbs > 125 Then
                            If check_sub = 0 Then
                                tab4_result_fbs.Text = "มีภาวะเบาหวาน แนะนำควรพบแพทย์"
                            ElseIf check_sub = 1 Then
                                tab4_result_fbs.Text = "Consult Doctor."
                            End If


                        ElseIf int_fbs < 50 Then
                            If check_sub = 0 Then
                                tab4_result_fbs.Text = "ภาวะน้ำตาลในเลือดต่ำ คำแนะนำควรพบแพทย์เพื่อหาสาเหตุ"
                            ElseIf check_sub = 1 Then
                                tab4_result_fbs.Text = "Consult Doctor."
                            End If

                        End If
                    End If





                    'tab5
                    If mySqlReader("R55") Is DBNull.Value Then
                        tab5_txt_bun.BackColor = Color.DarkSeaGreen
                    Else
                        tab5_txt_bun.Text = mySqlReader("R55")
                        Dim int_bun As Integer
                        int_bun = Integer.Parse(tab5_txt_bun.Text)
                        tab5_txt_bun.Text = int_bun

                        If int_bun >= 7 And int_bun <= 20 Then

                            tab5_result_bun.Text = "อยู่ในเกณฑ์ปกติ (Normal)"


                        ElseIf int_bun > 20 Then
                            If check_sub = 0 Then
                                tab5_result_bun.Text = "การทำงานของไตสูงกว่าปกติ คำแนะนำ ตรวจติดตามทุกปี"
                            ElseIf check_sub = 1 Then
                                tab5_result_bun.Text = "The hardness of renal function Follow up every year"
                            End If

                        ElseIf int_bun < 7 Then
                            If check_sub = 0 Then
                                tab5_result_bun.Text = "ไม่มีผลต่อการวินิจฉัย คำแนะนำ ตรวจติดตามทุกปี"
                            ElseIf check_sub = 1 Then
                                tab5_result_bun.Text = "Non affect to diagnose"

                            End If

                        End If
                    End If


                    If mySqlReader("R57") Is DBNull.Value Then
                        tab5_txt_cholesterol.BackColor = Color.DarkSeaGreen
                    Else
                        tab5_txt_cholesterol.Text = mySqlReader("R57")
                        Dim int_cholesterol As Integer
                        int_cholesterol = Integer.Parse(tab5_txt_cholesterol.Text)
                        tab5_txt_cholesterol.Text = int_cholesterol

                        If int_cholesterol >= 0 And int_cholesterol <= 200 Then
                            tab5_result_cholesterol.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                        ElseIf int_cholesterol > 200 Then

                            If check_sub = 0 Then
                                tab5_result_cholesterol.Text = "ไขมันในเลือดสูง คำแนะนำ หลีกเลี่ยงหรือลดอาหารประเภทไขมันมาก ได้แก่ อาหารทะเล ไข่แดง เครื่องในสัตว์เป็นต้น ออกกำลังกายสม่ำเสมอ และตรวจติดตาม หรือตามคำแนะนำของแพทย์"
                            ElseIf check_sub = 1 Then
                                tab5_result_cholesterol.Text = "High cholesterol levels Dyslipidemia  Avoid or reduce fat food, including seafood , egg, yolks etc. Exercise regulary and Follow up a Doctor's instroduction."

                            End If



                        End If
                    End If

                    If mySqlReader("R56") Is DBNull.Value Then
                        tab5_txt_creatinine.BackColor = Color.DarkSeaGreen
                    Else
                        tab5_txt_creatinine.Text = mySqlReader("R56")
                        Dim int_creatinine As Double
                        int_creatinine = Double.Parse(tab5_txt_creatinine.Text)
                        tab5_txt_creatinine.Text = int_creatinine

                        If int_creatinine >= 0.7 And int_creatinine <= 1.5 Then
                            tab5_result_creatinine.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                        ElseIf int_creatinine > 1.5 Then
                            If check_sub = 0 Then

                                tab5_result_creatinine.Text = "การทำงานของไตสูงกว่าปกติ คำแนะนำ ตรวจติดตามทุกปี"
                            ElseIf check_sub = 1 Then
                                tab5_result_creatinine.Text = "Renal Insuffciency Follow up every year"
                            End If

                        ElseIf int_creatinine < 0.7 Then

                            If check_sub = 0 Then
                                tab5_result_creatinine.Text = "ไม่มีผลต่อการวินิจฉัย คำแนะนำ ตรวจติดตามทุกปี"
                            ElseIf check_sub = 1 Then
                                tab5_result_creatinine.Text = "Non affect to diagnose"
                            End If
                        End If
                    End If


                    If mySqlReader("R59") Is DBNull.Value Then
                        tab5_txt_hdl.BackColor = Color.DarkSeaGreen
                    Else
                        tab5_txt_hdl.Text = mySqlReader("R59")

                        Dim int_hdl As Integer
                        int_hdl = Integer.Parse(tab5_txt_hdl.Text)
                        tab5_txt_hdl.Text = int_hdl

                        If int_hdl >= 40 And int_hdl <= 60 Then
                            tab5_result_hdl.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                        ElseIf int_hdl > 60 Then
                            If check_sub = 0 Then
                                tab5_result_hdl.Text = "มีระดับดี คำแนะนำ ลดภาวะเสี่ยงจากโรคหลอดเลือดหัวใจและหลอดเลือดสมองตีบ"
                            ElseIf check_sub = 1 Then
                                tab5_result_hdl.Text = "Great range May reduce the risk of Vascular disease and Heart disease."
                            End If


                        ElseIf int_hdl < 40 Then
                            If check_sub = 0 Then
                                tab5_result_hdl.Text = "ต่ำกว่าปกติ คำแนะนำ เพิ่มความเสี่ยงต่อโรคหลอดเลือดหัวใจและหลอดเลือดสมองตีบ"
                            ElseIf check_sub = 1 Then
                                tab5_result_hdl.Text = "May increase the risk of Vascular disease and Heart disease. Exercise regulary, no smoking, eat vegetables,more fish"
                            End If
                        End If
                    End If

                    If mySqlReader("R58") Is DBNull.Value Then
                        tab5_txt_trigyceride.BackColor = Color.DarkSeaGreen
                    Else
                        tab5_txt_trigyceride.Text = mySqlReader("R58")
                        Dim int_trigyceride As Integer
                        int_trigyceride = Integer.Parse(tab5_txt_trigyceride.Text)
                        tab5_txt_trigyceride.Text = int_trigyceride
                        If int_trigyceride >= 10 And int_trigyceride <= 150 Then
                            tab5_result_trigyceride.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                        ElseIf int_trigyceride > 150 Then
                            If check_sub = 0 Then
                                tab5_result_trigyceride.Text = "ไขมันในเลือดสูง คำแนะนำ หลีกเลี่ยงหรือลดอาหารประเภทแป้ง คาร์โบไฮเดรตสูง ของหวาน สุรา เบียร์ เป็นต้น ออกกำลังกายสม่ำเสมอและตรวจติดตาม หรือตามคำแนะนำของแพทย์"
                            ElseIf check_sub = 1 Then
                                tab5_result_trigyceride.Text = "High triglyceride levels Dyslipidemia Avoid or reduce flour,carbohydrate,desert,alcohol,beer etc. Exercise regulary and follow up or a Doctor's instroduction."
                            End If
                        End If
                    End If


                    If mySqlReader("R61") Is DBNull.Value Then
                        tab5_txt_uricacid.BackColor = Color.DarkSeaGreen
                    Else
                        tab5_txt_uricacid.Text = mySqlReader("R61")
                        Dim int_uricacid As Double
                        int_uricacid = Double.Parse(tab5_txt_uricacid.Text)
                        tab5_txt_uricacid.Text = int_uricacid

                        If int_uricacid >= 2.5 And int_uricacid <= 8.5 Then
                            tab5_result_uricacid.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                        ElseIf int_uricacid > 8.5 Then

                            If check_sub = 0 Then

                                tab5_result_uricacid.Text = "สูงกว่าปกติ คำแนะนำ ควรหลีกเลี่ยงการรับประทานอาหารประเภทสัตว์ปีก เครื่องในสัตว์ หรือผักบางชนิด ยอดผัก เช่น หน่อไม้ กระถิน กะหล่ำปลี แอลกอฮอล์ เหล้า เบียร์ และตรวจติดตาม"
                            ElseIf check_sub = 1 Then
                                tab5_result_uricacid.Text = "High than normal : Avoid eating poultry,animala'entrails, some vegetables such as asparagus,cabbage etc. alcohol,beer and Follow up."
                            End If


                        ElseIf int_uricacid < 2.5 Then

                            If check_sub = 0 Then
                                tab5_result_uricacid.Text = "ไม่มีผลต่อการวินิจฉัย คำแนะนำ ตรวจติดตามทุกปี"
                            ElseIf check_sub = 1 Then
                                tab5_result_uricacid.Text = "Non affect to diagnose : Follow up every year"
                            End If

                        End If

                    End If




                    If mySqlReader("R62") Is DBNull.Value Then
                        tab6_txt_alkaline.BackColor = Color.DarkSeaGreen
                    Else
                        tab6_txt_alkaline.Text = mySqlReader("R62")


                        Dim int_alk As Integer
                        int_alk = Integer.Parse(tab6_txt_alkaline.Text)
                        tab6_txt_alkaline.Text = int_alk

                        If int_alk >= 38 And int_alk <= 126 Then
                            tab6_result_alkaline.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                        ElseIf int_alk > 126 And int_alk < 199 Then

                            If check_sub = 0 Then
                                tab6_result_alkaline.Text = "สูงกว่าปกติ คำแนะนำ แนะนำตรวจติดตามและตรวจซ้ำภายใน 3 เดือน"
                            ElseIf check_sub = 1 Then
                                tab6_result_alkaline.Text = "Follow up and repeated blood test in 3 month"
                            End If

                        ElseIf int_alk > 200 Then
                            If check_sub = 0 Then
                                tab6_result_alkaline.Text = "สงสัยมีภาวะอุดกั้นทางเดินน้ำดี คำแนะนำ แนะนำปรึกษาแพทย์"
                            ElseIf check_sub = 1 Then
                                tab6_result_alkaline.Text = "Should Consult a Doctor"
                            End If
                        ElseIf int_alk < 38 Then

                            If check_sub = 0 Then
                                tab6_result_alkaline.Text = "ไม่มีผลต่อการวินิจฉัย คำแนะนำ ตรวจติดตาม"
                            ElseIf check_sub = 1 Then
                                tab6_result_alkaline.Text = "Non affect to diagnose Follow up every year"
                            End If

                        End If


                    End If
                    If mySqlReader("R60") Is DBNull.Value Then
                        tab6_txt_ldl.BackColor = Color.DarkSeaGreen
                    Else
                        tab6_txt_ldl.Text = mySqlReader("R60")
                        Dim int_ldl As Integer
                        int_ldl = Integer.Parse(tab6_txt_ldl.Text)
                        tab6_txt_ldl.Text = int_ldl

                        If int_ldl >= 30 And int_ldl <= 129 Then
                            tab6_result_ldl.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                        ElseIf int_ldl > 130 Then
                            If check_sub = 0 Then
                                tab6_result_ldl.Text = "ไขมันในเลือดสูง คำแนะนำ หลีกเลี่ยงหรือลดอาหารประเภทไขมันมาก ได้แก่ อาหารทะเล ไข่แดง เครื่องในสัตว์ เป็นต้น ออกกำลังกายสม่ำเสมอ และตรวจติดตาม หรือตามคำแนะนำของแพทย์"
                            ElseIf check_sub = 1 Then
                                tab6_result_ldl.Text = "High LDL Avoid or reduced fat foods, including seafood, egg,yolks etc, Exercise regulary and follow up or a Doctor's introduction."
                            End If


                        End If

                    End If
                    If mySqlReader("R70") Is DBNull.Value Then
                        tab6_txt_sgot.BackColor = Color.DarkSeaGreen
                    Else
                        tab6_txt_sgot.Text = mySqlReader("R70")

                        Dim int_sgot As Integer
                        int_sgot = Integer.Parse(tab6_txt_sgot.Text)
                        tab6_txt_sgot.Text = int_sgot

                        If int_sgot >= 15 And int_sgot <= 46 Then
                            tab6_result_sgot.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                        ElseIf int_sgot > 46 Then

                            If check_sub = 0 Then
                                tab6_result_sgot.Text = "เอนไซม์ตับสูงกว่าปกติ คำแนะนำ ควรลดอาหารไขมัน หลีกเลี่ยงแอลกอออล(ถ้าดื่ม) ออกกำลังกายสม่ำเสมอ และตรวจติดตาม"
                            ElseIf check_sub = 1 Then
                                tab6_result_sgot.Text = "High liver enzymes Reduce fat food, avoid alcohol (a drink), Exercise regulary and follow up."
                            End If

                        ElseIf int_sgot < 15 Then
                            If check_sub = 0 Then

                                tab6_result_sgot.Text = "ไม่มีผลต่อการวินิจฉัย คำแนะนำ ตรวจติดตามทุกปี"
                            ElseIf check_sub = 1 Then
                                tab6_result_sgot.Text = "Non affect to diagnose  Follow up very Year"
                            End If


                        ElseIf int_sgot > 100 Then
                            If check_sub = 0 Then
                                tab6_result_sgot.Text = "มีภาวะตับอักเสบ"
                            ElseIf check_sub = 1 Then
                                tab6_result_sgot.Text = "Hepatitis"
                            End If
                        End If

                    End If


                    If mySqlReader("R71") Is DBNull.Value Then
                        tab6_txt_sgpt.BackColor = Color.DarkSeaGreen
                    Else
                        tab6_txt_sgpt.Text = mySqlReader("R71")
                        Dim int_sgpt As Integer
                        int_sgpt = Integer.Parse(tab6_txt_sgpt.Text)
                        tab6_txt_sgpt.Text = int_sgpt

                        If int_sgpt >= 13 And int_sgpt <= 69 Then
                            tab6_result_spgt.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                        ElseIf int_sgpt > 69 Then

                            If check_sub = 0 Then
                                tab6_result_spgt.Text = "เอนไซม์ตับสูงกว่าปกติ คำแนะนำ ควรลดอาหารไขมัน หลีกเลี่ยงแอลกอออล(ถ้าดื่ม) ออกกำลังกายสม่ำเสมอ และตรวจติดตาม"

                            ElseIf check_sub = 1 Then
                                tab6_result_spgt.Text = "High liver enzymes Reduce fat food,avoid alcohol (a drink) Exercise regulary and follow up."
                            End If

                        ElseIf int_sgpt < 13 Then

                            If check_sub = 0 Then
                                tab6_result_spgt.Text = "ไม่มีผลต่อการวินิจฉัย"
                            ElseIf check_sub = 1 Then
                                tab6_result_spgt.Text = "Non affect to diagnose"
                            End If

                        End If
                    End If

                End While
                mysql.Close()

            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try



        End If


    End Sub
    Private Sub ComboBox8_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox8.SelectedValueChanged
        If ComboBox8.Text = "1.ปกติ" Then
            tab4_result_phy.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
        ElseIf ComboBox8.Text = "2.ผิดปกติ" Then
            tab4_result_phy.Text = "กรุณากรอกข้อมูล"
        End If
    End Sub
    Private Sub ComboBox4_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox4.SelectedValueChanged
        If ComboBox4.Text = "1.ปกติ" Then
            tab4_result_x_ray.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
        ElseIf ComboBox4.Text = "2.ผิดปกติ" Then
            tab4_result_x_ray.Text = "กรุณากรอกข้อมูล"
        End If
    End Sub
    Private Sub ComboBox6_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox6.SelectedValueChanged
        If ComboBox6.Text = "1.ปกติ" Then
            tab4_result_ekg.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
        ElseIf ComboBox6.Text = "2.ผิดปกติ" Then
            tab4_result_ekg.Text = "กรุณากรอกข้อมูล"
        End If
    End Sub
    Private Sub ComboBox22_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox22.SelectedValueChanged
        If ComboBox22.Text = "1.ปกติ" Then
            tab1_result_pulse.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
        ElseIf ComboBox22.Text = "2.ผิดปกติ" Then
            tab1_result_pulse.Text = "กรุณากรอกข้อมูล"
        End If
    End Sub
    Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged
        If ComboBox3.Text = "1.ปกติ" Then
            tab2_result_redmorphology.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
        ElseIf ComboBox3.Text = "2.ผิดปกติ" Then
            tab2_result_redmorphology.Text = "กรุณากรอกข้อมูล"
        End If
    End Sub
    Private Sub ComboBox21_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox21.SelectedIndexChanged
        If ComboBox21.Text = "1.ปกติ" Then
            tab2_result_platecount.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
        ElseIf ComboBox21.Text = "2.ผิดปกติ" Then
            tab2_result_platecount.Text = "กรุณากรอกข้อมูล"
        End If
    End Sub
    Private Sub ComboBox1_SelectedValueChanged1(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedValueChanged
        If ComboBox1.Text = "1.ปกติ" Then
            tab3_txt_comment.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
        ElseIf ComboBox1.Text = "2.ผิดปกติ" Then
            tab3_txt_comment.Text = "กรุณากรอกข้อมูล"
        End If
    End Sub
    Private Sub clear()
        check_group = " "
        count_group = 1
        check_form = "0"

        result_all = " "
        urine_other = " "
        under = " "

        tab1_txt_height.Text = " "
        tab1_tab_weight.Text = " "
        red_homology = " "
        address = " "
        export_date = " "
        tellephone = " "
        result_phy = " "
        result_hematology = " "
        result_urine = " "
        result_physical = " "
        result_xray = " "
        result_ultrasound = " "
        result_ekg = " "
        result_bloodchem = " "
        result_bun = " "
        result_creatinine = " "
        result_uricacid = " "
        result_cholesterol = " "
        result_triglyceride = " "
        result_hdl = " "
        result_ldl = " "
        result_sgot = " "
        result_sgpt = " "
        result_alkaline = " "
        result_afp = " "
        result_pfp = " "
        result_fbs = " "
        phy_height = " "
        phy_weight = " "
        phy_bmi = " "
        phy_bloodpressure = " "
        phy_pulse = " "
        phy_eye_left = " "
        phy_eye_right = " "
        phy_dental = " "
        tab2_redcell = " "


        result_all = " "
        'tab2 
        tab2_txt_hb.BackColor = Color.Empty
        tab2_txt_hct.BackColor = Color.Empty
        tab2_txt_atypical.BackColor = Color.Empty
        tab2_txt_bashophils.BackColor = Color.Empty
        tab2_txt_eosinophils.BackColor = Color.Empty
        tab2_txt_groupblood.BackColor = Color.Empty
        tab2_txt_lymphocytes.BackColor = Color.Empty
        tab2_txt_neutrophils.BackColor = Color.Empty
        tab2_txt_plate.BackColor = Color.Empty
        tab2_txt_redcell.BackColor = Color.Empty
        tab2_txt_wbc.BackColor = Color.Empty
        tab2_txt_monocytes.BackColor = Color.Empty

        tab2_txt_monocytes.Text = " "
        tab2_txt_wbc.Text = " "
        tab2_txt_rh.Text = " "
        tab2_txt_wbc.Text = " "
        tab2_txt_hb.Text = " "
        tab2_txt_hct.Text = " "
        tab2_txt_atypical.Text = " "
        tab2_txt_bashophils.Text = " "
        tab2_txt_eosinophils.Text = " "
        tab2_txt_groupblood.Text = " "
        tab2_txt_lymphocytes.Text = " "
        tab2_txt_neutrophils.Text = " "
        tab2_txt_plate.Text = " "
        tab2_txt_redcell.Text = " "
        tab2_txt_rh.Text = " "
        tab2_txt_wbc.Text = " "
        tab2_result_platecount.Text = " "


        'tab 3
        tab3_txt_albumin.BackColor = Color.Empty
        tab3_txt_albumin.Text = " "

        tab3_txt_appearance.BackColor = Color.Empty
        tab3_txt_appearance.Text = " "

        tab3_txt_blood.BackColor = Color.Empty
        tab3_txt_blood.Text = " "

        tab3_txt_color.BackColor = Color.Empty
        tab3_txt_color.Text = " "

        tab3_txt_comment.BackColor = Color.Empty
        tab3_txt_comment.Text = " "

        tab3_txt_epi.BackColor = Color.Empty
        tab3_txt_epi.Text = " "

        tab3_txt_glucose.BackColor = Color.Empty
        tab3_txt_glucose.Text = " "

        tab3_txt_other.BackColor = Color.Empty
        tab3_txt_other.Text = " "

        tab3_txt_ph.BackColor = Color.Empty
        tab3_txt_ph.Text = " "

        tab3_txt_rbc.BackColor = Color.Empty
        tab3_txt_rbc.Text = " "

        tab3_txt_spgr.BackColor = Color.Empty
        tab3_txt_spgr.Text = " "

        tab3_txt_wbc.BackColor = Color.Empty

        tab3_txt_wbc.Text = " "
        tab3_txt_comment.Text = " "
        tab4_result_ekg.Text = " "
        tab4_result_fbs.Text = " "
        tab4_result_phy.Text = " "

        tab4_result_x_ray.Text = " "


        tab4_txt_fbs.Text = " "
        tab4_txt_fbs.BackColor = Color.Empty
        tab4_result_fbs.Text = " "

        'tab5
        tab5_txt_bun.BackColor = Color.Empty
        tab5_txt_bun.Text = " "
        tab5_result_bun.Text = " "

        tab5_txt_cholesterol.BackColor = Color.Empty
        tab5_txt_cholesterol.Text = " "
        tab5_result_cholesterol.Text = " "
        tab5_txt_creatinine.BackColor = Color.Empty
        tab5_txt_creatinine.Text = " "
        tab5_result_creatinine.Text = " "
        tab5_txt_hdl.BackColor = Color.Empty
        tab5_txt_hdl.Text = " "
        tab5_result_hdl.Text = " "
        tab5_txt_trigyceride.BackColor = Color.Empty
        tab5_txt_trigyceride.Text = " "
        tab5_result_trigyceride.Text = " "
        tab5_txt_uricacid.BackColor = Color.Empty
        tab5_txt_uricacid.Text = " "
        tab5_result_uricacid.Text = " "

        'tab6.

        tab6_txt_alkaline.BackColor = Color.Empty
        tab6_txt_alkaline.Text = " "
        tab6_result_alkaline.Text = " "
        tab6_txt_ldl.BackColor = Color.Empty
        tab6_txt_ldl.Text = " "
        tab6_result_ldl.Text = " "


        tab6_txt_sgot.BackColor = Color.Empty
        tab6_txt_sgot.Text = " "
        tab6_result_sgot.Text = " "

        tab6_txt_sgpt.BackColor = Color.Empty
        tab6_txt_sgpt.Text = " "
        tab6_result_spgt.Text = " "



        Me.Refresh()
    End Sub
  
    Private Sub txtsearch_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtsearch.KeyDown


        Dim string_count As Integer = 0
        Dim string_redcell As String = " "

        count_result = 1
        If e.KeyCode = "13" Then

            clear()
            id_hn = txtsearch.Text
            Dim mySqlCommand As New MySqlCommand
            Dim mySqlAdaptor As New MySqlDataAdapter
            Dim mySqlReader As MySqlDataReader
            Dim amp As String
            Dim prv As String
            Dim tmp As String
            Dim zipcode As String

            Dim MyODBCConnection As New OdbcConnection("dsn=RYHPFV5; Userid=mse;Password=m0116;")     'Open the connection
            Try
                MyODBCConnection.Open()
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try

            ' Dim selectCMD As OdbcCommand = New OdbcCommand("SELECT * FROM REGMASV5PF WHERE RMSHNNO='7708' and RMSHNYR = '56'")
            Dim selectCMD As OdbcCommand = New OdbcCommand("SELECT * FROM REGDETV5PF WHERE RDTHN = '" & id_hn & "'")

            selectCMD.Connection = MyODBCConnection


            Try
                'Set the mouse to show a Wait cursor
                Dim dr As OdbcDataReader = selectCMD.ExecuteReader
                'start the Read loop
                While dr.Read
                    'Note: the numbers in double quotes represent the column number from the AS400 database
                    'Add the data to the list view
                    address_text = dr.GetString(2).Trim

                    txt_tell.Text = dr.GetString(9).Trim

                    amp = dr.GetString(4)
                    prv = dr.GetString(3)
                    tmp = dr.GetString(5)
                    zipcode = dr.GetString(6)
                    'End the loop
                End While
                'Reset the cursor


            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try


            MyODBCConnection.Close()

            If MyODBCConnection.State = ConnectionState.Closed Then
                MyODBCConnection.Open()
            End If

            selectCMD = New OdbcCommand("SELECT TPVPRVNAM,TMPAMPNAM,TBNTBNNAM FROM TABPRVV5PF,TABAMPV5PF,TABTBNV5PF WHERE TABPRVV5PF.TPVPRVCOD = TABAMPV5PF.TMPPRVCOD AND TABAMPV5PF.TMPAMPCOD = TABTBNV5PF.TBNAMPCOD AND TABAMPV5PF.TMPPRVCOD = TABTBNV5PF.TBNPRVCOD AND (TABAMPV5PF.TMPPRVCOD = '" & prv & "') AND (TABTBNV5PF.TBNTBNCOD = '" & tmp & "') AND (TABAMPV5PF.TMPAMPCOD = '" & amp & "')")

            selectCMD.Connection = MyODBCConnection




            Try
                'Set the mouse to show a Wait cursor
                Dim dr As OdbcDataReader = selectCMD.ExecuteReader
                'start the Read loop
                While dr.Read
                    If dr.GetString(2) IsNot DBNull.Value Then
                        address_text = address_text + " ตำบล " + dr.GetString(2).Trim

                    End If
                    If dr.GetString(1) IsNot DBNull.Value Then

                        address_text = address_text + " อำเภอ " + dr.GetString(1).Trim

                    End If
                    If dr.GetString(0) IsNot DBNull.Value Then
                        address_text = address_text + " จังหวัด " + dr.GetString(0).Trim

                    End If

                    address_text = address_text + " " + zipcode
                End While

            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
            txt_address.Text = address_text
            MyODBCConnection.Close()



            If mysql.State = ConnectionState.Closed Then
                mysql.Open()
            End If
            mySqlCommand.CommandText = "Select * from checkup_export where hn like '" + txtsearch.Text + "';"
            mySqlCommand.Connection = mysql
            mySqlAdaptor.SelectCommand = mySqlCommand

            Try

                mySqlReader = mySqlCommand.ExecuteReader
                While mySqlReader.Read()
                    string_count = string_count + 1

                End While
                mysql.Close()


                If string_count = 1 Then


                    If mysql.State = ConnectionState.Closed Then
                        mysql.Open()
                    End If
                    mySqlCommand.CommandText = "Select * from checkup_export where hn like '" + txtsearch.Text + "';"
                    mySqlCommand.Connection = mysql
                    mySqlAdaptor.SelectCommand = mySqlCommand

                    mySqlReader = mySqlCommand.ExecuteReader
                    While mySqlReader.Read()

                        txt_name.Text = "คุณ " + mySqlReader("f_name") + " " + mySqlReader("l_name")
                        If mySqlReader("sex_code") = "3" Then
                            txt_sex.Text = "หญิง"
                        Else
                            txt_sex.Text = "ชาย"
                        End If

                        txt_age.Text = mySqlReader("age_y")
                        txt_date.Text = mySqlReader("export_date")

                        'tab2

                        If mySqlReader("R17") Is "Normal" Then

                            tab2_txt_redcell.Text = "อยู่ในเกณฑ์ปกติ(Normal Value)"

                        ElseIf mySqlReader("R17") Is DBNull.Value Then

                            If mySqlReader("R18") Is DBNull.Value Then

                            Else
                                string_redcell = string_redcell + "Hypochromia-few,"
                            End If

                            If mySqlReader("R19") Is DBNull.Value Then
                            Else
                                string_redcell = string_redcell + "Anisocytosis-few,"
                            End If
                            If mySqlReader("R20") Is DBNull.Value Then
                            Else
                                string_redcell = string_redcell + "Microcyte-few,"
                            End If
                            If mySqlReader("R21") Is DBNull.Value Then
                            Else
                                string_redcell = string_redcell + "Macrocyte-few,"
                            End If
                            If mySqlReader("R22") Is DBNull.Value Then
                            Else
                                string_redcell = string_redcell + "Poikilocytosis-few,"
                            End If
                            If mySqlReader("R23") Is DBNull.Value Then
                            Else
                                string_redcell = string_redcell + "Ovalocyte-few,"
                            End If

                            If mySqlReader("R24") Is DBNull.Value Then
                            Else
                                string_redcell = string_redcell + "Schistocyte-few,"
                            End If
                            If mySqlReader("R25") Is DBNull.Value Then
                            Else
                                string_redcell = string_redcell + "Burr-few,"
                            End If
                            If mySqlReader("R26") Is DBNull.Value Then
                            Else
                                string_redcell = string_redcell + "Target Cell-few,"
                            End If
                            If mySqlReader("R27") Is DBNull.Value Then
                            Else
                                string_redcell = string_redcell + "Polychromasia-few,"
                            End If
                            If mySqlReader("R28") Is DBNull.Value Then
                            Else
                                string_redcell = string_redcell + "Basophilic-few"
                            End If


                            tab2_txt_redcell.Text = string_redcell
                        End If

                        If mySqlReader("R79") Is DBNull.Value Then
                            tab2_txt_groupblood.BackColor = Color.DarkSeaGreen
                        Else
                            tab2_txt_groupblood.Text = mySqlReader("R79")

                        End If
                        If mySqlReader("R79") Is DBNull.Value Then
                            tab2_txt_rh.BackColor = Color.DarkSeaGreen
                        Else
                            tab2_txt_rh.Text = mySqlReader("R80")

                        End If

                        If mySqlReader("R3") Is DBNull.Value Then
                            tab2_txt_hb.BackColor = Color.DarkSeaGreen
                        Else
                            tab2_txt_hb.Text = mySqlReader("R3")

                        End If
                        If mySqlReader("R4") Is DBNull.Value Then
                            tab2_txt_hct.BackColor = Color.DarkSeaGreen
                        Else

                            tab2_txt_hct.Text = mySqlReader("R4")

                        End If
                        If mySqlReader("R1") Is DBNull.Value Then
                            tab2_txt_wbc.BackColor = Color.DarkSeaGreen
                        Else

                            tab2_txt_wbc.Text = mySqlReader("R1")
                        End If
                        If mySqlReader("R15") Is DBNull.Value Then
                            tab2_txt_atypical.BackColor = Color.DarkSeaGreen
                        Else
                            tab2_txt_atypical.Text = mySqlReader("R15")

                        End If

                        If mySqlReader("R14") Is DBNull.Value Then


                            tab2_txt_bashophils.BackColor = Color.DarkSeaGreen
                        Else
                            tab2_txt_bashophils.Text = mySqlReader("R14")
                        End If

                        If mySqlReader("R13") Is DBNull.Value Then
                            tab2_txt_eosinophils.BackColor = Color.DarkSeaGreen
                        Else

                            tab2_txt_eosinophils.Text = mySqlReader("R13")
                        End If

                        If mySqlReader("R11") Is DBNull.Value Then
                            tab2_txt_lymphocytes.BackColor = Color.DarkSeaGreen
                        Else
                            tab2_txt_lymphocytes.Text = mySqlReader("R11")
                        End If

                        If mySqlReader("R12") Is DBNull.Value Then
                            tab2_txt_monocytes.BackColor = Color.DarkSeaGreen
                        Else
                            tab2_txt_monocytes.Text = mySqlReader("R12")
                        End If

                        If mySqlReader("R10") Is DBNull.Value Then
                            tab2_txt_neutrophils.BackColor = Color.DarkSeaGreen
                        Else
                            tab2_txt_neutrophils.Text = mySqlReader("R12")
                        End If


                        If mySqlReader("R8") Is DBNull.Value Then
                            tab2_txt_plate.BackColor = Color.DarkSeaGreen
                        Else
                            tab2_txt_plate.Text = mySqlReader("R8")
                        End If


                        ' tab3


                        If mySqlReader("R32") Is DBNull.Value Then
                            tab3_txt_color.BackColor = Color.DarkSeaGreen
                        Else
                            tab3_txt_color.Text = mySqlReader("R32")
                        End If


                        If mySqlReader("R33") Is DBNull.Value Then
                            tab3_txt_appearance.BackColor = Color.DarkSeaGreen
                        Else
                            tab3_txt_appearance.Text = mySqlReader("R33")
                        End If

                        If mySqlReader("R34") Is DBNull.Value Then
                            tab3_txt_spgr.BackColor = Color.DarkSeaGreen
                        Else
                            tab3_txt_spgr.Text = mySqlReader("R34")
                        End If
                        If mySqlReader("R36") Is DBNull.Value Then
                            tab3_txt_albumin.BackColor = Color.DarkSeaGreen
                        Else
                            tab3_txt_albumin.Text = mySqlReader("R36")
                        End If

                        If mySqlReader("R37") Is DBNull.Value Then
                            tab3_txt_glucose.BackColor = Color.DarkSeaGreen
                        Else
                            tab3_txt_glucose.Text = mySqlReader("R37")
                        End If



                        If mySqlReader("R41") Is DBNull.Value Then
                            tab3_txt_blood.BackColor = Color.DarkSeaGreen
                        Else
                            tab3_txt_blood.Text = mySqlReader("R41")
                        End If

                        If mySqlReader("R35") Is DBNull.Value Then
                            tab3_txt_ph.BackColor = Color.DarkSeaGreen
                        Else
                            tab3_txt_ph.Text = mySqlReader("R35")
                        End If


                        If mySqlReader("R44") Is DBNull.Value Then
                            tab3_txt_rbc.BackColor = Color.DarkSeaGreen
                        Else
                            tab3_txt_rbc.Text = mySqlReader("R44")
                        End If


                        If mySqlReader("R45") Is DBNull.Value Then
                            tab3_txt_wbc.BackColor = Color.DarkSeaGreen
                        Else
                            tab3_txt_wbc.Text = mySqlReader("R45")
                        End If


                        If mySqlReader("R46") Is DBNull.Value Then
                            tab3_txt_epi.BackColor = Color.DarkSeaGreen
                        Else
                            tab3_txt_epi.Text = mySqlReader("R46")
                        End If




                        'tab4

                        If mySqlReader("R54") Is DBNull.Value Then
                            tab4_txt_fbs.BackColor = Color.DarkSeaGreen
                        Else
                            tab4_txt_fbs.Text = mySqlReader("R54")

                            Dim int_fbs As Integer
                            int_fbs = Integer.Parse(tab4_txt_fbs.Text)
                            tab4_txt_fbs.Text = int_fbs

                            If int_fbs >= 70 And int_fbs <= 110 Then
                                tab4_result_fbs.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                            ElseIf int_fbs > 111 And int_fbs <= 125 Then
                                If check_sub = 0 Then
                                    tab4_result_fbs.Text = "การควบคุมน้ำตาลบกพร่อง คำแนะนำ ควรลดอาหาร แป้ง รับประทานผัก ผลไม้ มากขึ้น และตรวจซ้ำ 1 เดือน"
                                ElseIf check_sub = 1 Then
                                    tab4_result_fbs.Text = "Impaired glucose control : Reduce sweet foods,flour.Eat more fruit and vegetables and repeat blood test in 1 month."

                                End If

                            ElseIf int_fbs > 125 Then
                                If check_sub = 0 Then
                                    tab4_result_fbs.Text = "มีภาวะเบาหวาน แนะนำควรพบแพทย์"
                                ElseIf check_sub = 1 Then
                                    tab4_result_fbs.Text = "Consult Doctor."
                                End If


                            ElseIf int_fbs < 50 Then
                                If check_sub = 0 Then
                                    tab4_result_fbs.Text = "ภาวะน้ำตาลในเลือดต่ำ คำแนะนำควรพบแพทย์เพื่อหาสาเหตุ"
                                ElseIf check_sub = 1 Then
                                    tab4_result_fbs.Text = "Consult Doctor."
                                End If

                            End If
                        End If





                        'tab5
                        If mySqlReader("R55") Is DBNull.Value Then
                            tab5_txt_bun.BackColor = Color.DarkSeaGreen
                        Else
                            tab5_txt_bun.Text = mySqlReader("R55")
                            Dim int_bun As Integer
                            int_bun = Integer.Parse(tab5_txt_bun.Text)
                            tab5_txt_bun.Text = int_bun

                            If int_bun >= 7 And int_bun <= 20 Then

                                tab5_result_bun.Text = "อยู่ในเกณฑ์ปกติ (Normal)"


                            ElseIf int_bun > 20 Then
                                If check_sub = 0 Then
                                    tab5_result_bun.Text = "การทำงานของไตสูงกว่าปกติ คำแนะนำ ตรวจติดตามทุกปี"
                                ElseIf check_sub = 1 Then
                                    tab5_result_bun.Text = "The hardness of renal function Follow up every year"
                                End If

                            ElseIf int_bun < 7 Then
                                If check_sub = 0 Then
                                    tab5_result_bun.Text = "ไม่มีผลต่อการวินิจฉัย คำแนะนำ ตรวจติดตามทุกปี"
                                ElseIf check_sub = 1 Then
                                    tab5_result_bun.Text = "Non affect to diagnose"

                                End If

                            End If
                        End If


                        If mySqlReader("R57") Is DBNull.Value Then
                            tab5_txt_cholesterol.BackColor = Color.DarkSeaGreen
                        Else
                            tab5_txt_cholesterol.Text = mySqlReader("R57")
                            Dim int_cholesterol As Integer
                            int_cholesterol = Integer.Parse(tab5_txt_cholesterol.Text)
                            tab5_txt_cholesterol.Text = int_cholesterol

                            If int_cholesterol >= 0 And int_cholesterol <= 200 Then
                                tab5_result_cholesterol.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                            ElseIf int_cholesterol > 200 Then

                                If check_sub = 0 Then
                                    tab5_result_cholesterol.Text = "ไขมันในเลือดสูง คำแนะนำ หลีกเลี่ยงหรือลดอาหารประเภทไขมันมาก ได้แก่ อาหารทะเล ไข่แดง เครื่องในสัตว์เป็นต้น ออกกำลังกายสม่ำเสมอ และตรวจติดตาม หรือตามคำแนะนำของแพทย์"
                                ElseIf check_sub = 1 Then
                                    tab5_result_cholesterol.Text = "High cholesterol levels Dyslipidemia  Avoid or reduce fat food, including seafood , egg, yolks etc. Exercise regulary and Follow up a Doctor's instroduction."

                                End If



                            End If
                        End If

                        If mySqlReader("R56") Is DBNull.Value Then
                            tab5_txt_creatinine.BackColor = Color.DarkSeaGreen
                        Else
                            tab5_txt_creatinine.Text = mySqlReader("R56")
                            Dim int_creatinine As Double
                            int_creatinine = Double.Parse(tab5_txt_creatinine.Text)
                            tab5_txt_creatinine.Text = int_creatinine

                            If int_creatinine >= 0.7 And int_creatinine <= 1.5 Then
                                tab5_result_creatinine.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                            ElseIf int_creatinine > 1.5 Then
                                If check_sub = 0 Then

                                    tab5_result_creatinine.Text = "การทำงานของไตสูงกว่าปกติ คำแนะนำ ตรวจติดตามทุกปี"
                                ElseIf check_sub = 1 Then
                                    tab5_result_creatinine.Text = "Renal Insuffciency Follow up every year"

                                End If

                            ElseIf int_creatinine < 0.7 Then

                                If check_sub = 0 Then
                                    tab5_result_creatinine.Text = "ไม่มีผลต่อการวินิจฉัย คำแนะนำ ตรวจติดตามทุกปี"
                                ElseIf check_sub = 1 Then
                                    tab5_result_creatinine.Text = "Non affect to diagnose"
                                End If
                            End If
                        End If


                        If mySqlReader("R59") Is DBNull.Value Then
                            tab5_txt_hdl.BackColor = Color.DarkSeaGreen
                        Else
                            tab5_txt_hdl.Text = mySqlReader("R59")

                            Dim int_hdl As Integer
                            int_hdl = Integer.Parse(tab5_txt_hdl.Text)
                            tab5_txt_hdl.Text = int_hdl

                            If int_hdl >= 40 And int_hdl <= 60 Then
                                tab5_result_hdl.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                            ElseIf int_hdl > 60 Then
                                If check_sub = 0 Then
                                    tab5_result_hdl.Text = "มีระดับดี คำแนะนำ ลดภาวะเสี่ยงจากโรคหลอดเลือดหัวใจและหลอดเลือดสมองตีบ"
                                ElseIf check_sub = 1 Then
                                    tab5_result_hdl.Text = "Great range May reduce the risk of Vascular disease and Heart disease."
                                End If


                            ElseIf int_hdl < 40 Then
                                If check_sub = 0 Then
                                    tab5_result_hdl.Text = "ต่ำกว่าปกติ คำแนะนำ เพิ่มความเสี่ยงต่อโรคหลอดเลือดหัวใจและหลอดเลือดสมองตีบ"
                                ElseIf check_sub = 1 Then
                                    tab5_result_hdl.Text = "May increase the risk of Vascular disease and Heart disease. Exercise regulary, no smoking, eat vegetables,more fish"
                                End If

                            End If
                        End If



                        If mySqlReader("R58") Is DBNull.Value Then
                            tab5_txt_trigyceride.BackColor = Color.DarkSeaGreen
                        Else
                            tab5_txt_trigyceride.Text = mySqlReader("R58")
                            Dim int_trigyceride As Integer
                            int_trigyceride = Integer.Parse(tab5_txt_trigyceride.Text)
                            tab5_txt_trigyceride.Text = int_trigyceride

                            If int_trigyceride >= 10 And int_trigyceride <= 150 Then
                                tab5_result_trigyceride.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                            ElseIf int_trigyceride > 150 Then
                                If check_sub = 0 Then

                                    tab5_result_trigyceride.Text = "ไขมันในเลือดสูง คำแนะนำ หลีกเลี่ยงหรือลดอาหารประเภทแป้ง คาร์โบไฮเดรตสูง ของหวาน สุรา เบียร์ เป็นต้น ออกกำลังกายสม่ำเสมอและตรวจติดตาม หรือตามคำแนะนำของแพทย์"
                                ElseIf check_sub = 1 Then
                                    tab5_result_trigyceride.Text = "High triglyceride levels Dyslipidemia Avoid or reduce flour,carbohydrate,desert,alcohol,beer etc. Exercise regulary and follow up or a Doctor's instroduction."
                                End If


                            End If


                        End If


                        If mySqlReader("R61") Is DBNull.Value Then
                            tab5_txt_uricacid.BackColor = Color.DarkSeaGreen
                        Else
                            tab5_txt_uricacid.Text = mySqlReader("R61")
                            Dim int_uricacid As Double
                            int_uricacid = Double.Parse(tab5_txt_uricacid.Text)
                            tab5_txt_uricacid.Text = int_uricacid

                            If int_uricacid >= 2.5 And int_uricacid <= 8.5 Then
                                tab5_result_uricacid.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                            ElseIf int_uricacid > 8.5 Then

                                If check_sub = 0 Then

                                    tab5_result_uricacid.Text = "สูงกว่าปกติ คำแนะนำ ควรหลีกเลี่ยงการรับประทานอาหารประเภทสัตว์ปีก เครื่องในสัตว์ หรือผักบางชนิด ยอดผัก เช่น หน่อไม้ กระถิน กะหล่ำปลี แอลกอฮอล์ เหล้า เบียร์ และตรวจติดตาม"
                                ElseIf check_sub = 1 Then
                                    tab5_result_uricacid.Text = "High than normal : Avoid eating poultry,animala'entrails, some vegetables such as asparagus,cabbage etc. alcohol,beer and Follow up."
                                End If


                            ElseIf int_uricacid < 2.5 Then

                                If check_sub = 0 Then
                                    tab5_result_uricacid.Text = "ไม่มีผลต่อการวินิจฉัย คำแนะนำ ตรวจติดตามทุกปี"
                                ElseIf check_sub = 1 Then
                                    tab5_result_uricacid.Text = "Non affect to diagnose : Follow up every year"
                                End If

                            End If

                        End If


                        'tab6


                        If mySqlReader("R62") Is DBNull.Value Then
                            tab6_txt_alkaline.BackColor = Color.DarkSeaGreen
                        Else
                            tab6_txt_alkaline.Text = mySqlReader("R62")


                            Dim int_alk As Integer
                            int_alk = Integer.Parse(tab6_txt_alkaline.Text)
                            tab6_txt_alkaline.Text = int_alk

                            If int_alk >= 38 And int_alk <= 126 Then
                                tab6_result_alkaline.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                            ElseIf int_alk > 126 And int_alk < 199 Then

                                If check_sub = 0 Then
                                    tab6_result_alkaline.Text = "สูงกว่าปกติ คำแนะนำ แนะนำตรวจติดตามและตรวจซ้ำภายใน 3 เดือน"
                                ElseIf check_sub = 1 Then
                                    tab6_result_alkaline.Text = "Follow up and repeated blood test in 3 month"
                                End If

                            ElseIf int_alk > 200 Then
                                If check_sub = 0 Then
                                    tab6_result_alkaline.Text = "สงสัยมีภาวะอุดกั้นทางเดินน้ำดี คำแนะนำ แนะนำปรึกษาแพทย์"
                                ElseIf check_sub = 1 Then
                                    tab6_result_alkaline.Text = "Should Consult a Doctor"
                                End If
                            ElseIf int_alk < 38 Then

                                If check_sub = 0 Then
                                    tab6_result_alkaline.Text = "ไม่มีผลต่อการวินิจฉัย คำแนะนำ ตรวจติดตาม"
                                ElseIf check_sub = 1 Then
                                    tab6_result_alkaline.Text = "Non affect to diagnose Follow up every year"
                                End If

                            End If


                        End If
                        If mySqlReader("R60") Is DBNull.Value Then
                            tab6_txt_ldl.BackColor = Color.DarkSeaGreen
                        Else
                            tab6_txt_ldl.Text = mySqlReader("R60")
                            Dim int_ldl As Integer
                            int_ldl = Integer.Parse(tab6_txt_ldl.Text)
                            tab6_txt_ldl.Text = int_ldl

                            If int_ldl >= 30 And int_ldl <= 129 Then
                                tab6_result_ldl.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                            ElseIf int_ldl > 130 Then
                                If check_sub = 0 Then
                                    tab6_result_ldl.Text = "ไขมันในเลือดสูง คำแนะนำ หลีกเลี่ยงหรือลดอาหารประเภทไขมันมาก ได้แก่ อาหารทะเล ไข่แดง เครื่องในสัตว์ เป็นต้น ออกกำลังกายสม่ำเสมอ และตรวจติดตาม หรือตามคำแนะนำของแพทย์"
                                ElseIf check_sub = 1 Then
                                    tab6_result_ldl.Text = "High LDL Avoid or reduced fat foods, including seafood, egg,yolks etc, Exercise regulary and follow up or a Doctor's introduction."
                                End If


                            End If

                        End If
                        If mySqlReader("R70") Is DBNull.Value Then
                            tab6_txt_sgot.BackColor = Color.DarkSeaGreen
                        Else
                            tab6_txt_sgot.Text = mySqlReader("R70")

                            Dim int_sgot As Integer
                            int_sgot = Integer.Parse(tab6_txt_sgot.Text)
                            tab6_txt_sgot.Text = int_sgot

                            If int_sgot >= 15 And int_sgot <= 46 Then
                                tab6_result_sgot.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                            ElseIf int_sgot > 46 Then

                                If check_sub = 0 Then
                                    tab6_result_sgot.Text = "เอนไซม์ตับสูงกว่าปกติ คำแนะนำ ควรลดอาหารไขมัน หลีกเลี่ยงแอลกอออล(ถ้าดื่ม) ออกกำลังกายสม่ำเสมอ และตรวจติดตาม"
                                ElseIf check_sub = 1 Then
                                    tab6_result_sgot.Text = "High liver enzymes Reduce fat food, avoid alcohol (a drink), Exercise regulary and follow up."
                                End If

                            ElseIf int_sgot < 15 Then
                                If check_sub = 0 Then

                                    tab6_result_sgot.Text = "ไม่มีผลต่อการวินิจฉัย คำแนะนำ ตรวจติดตามทุกปี"
                                ElseIf check_sub = 1 Then
                                    tab6_result_sgot.Text = "Non affect to diagnose  Follow up very Year"
                                End If


                            ElseIf int_sgot > 100 Then
                                If check_sub = 0 Then
                                    tab6_result_sgot.Text = "มีภาวะตับอักเสบ"
                                ElseIf check_sub = 1 Then
                                    tab6_result_sgot.Text = "Hepatitis"
                                End If
                            End If

                        End If


                        If mySqlReader("R71") Is DBNull.Value Then
                            tab6_txt_sgpt.BackColor = Color.DarkSeaGreen
                        Else
                            tab6_txt_sgpt.Text = mySqlReader("R71")
                            Dim int_sgpt As Integer
                            int_sgpt = Integer.Parse(tab6_txt_sgpt.Text)
                            tab6_txt_sgpt.Text = int_sgpt

                            If int_sgpt >= 13 And int_sgpt <= 69 Then
                                tab6_result_spgt.Text = "อยู่ในเกณฑ์ปกติ (Normal)"
                            ElseIf int_sgpt > 69 Then

                                If check_sub = 0 Then
                                    tab6_result_spgt.Text = "เอนไซม์ตับสูงกว่าปกติ คำแนะนำ ควรลดอาหารไขมัน หลีกเลี่ยงแอลกอออล(ถ้าดื่ม) ออกกำลังกายสม่ำเสมอ และตรวจติดตาม"

                                ElseIf check_sub = 1 Then
                                    tab6_result_spgt.Text = "High liver enzymes Reduce fat food,avoid alcohol (a drink) Exercise regulary and follow up."
                                End If

                            ElseIf int_sgpt < 13 Then

                                If check_sub = 0 Then
                                    tab6_result_spgt.Text = "ไม่มีผลต่อการวินิจฉัย"
                                ElseIf check_sub = 1 Then
                                    tab6_result_spgt.Text = "Non affect to diagnose"
                                End If

                            End If
                        End If

                    End While
                    mysql.Close()





                Else


                    Dim NextForm As frmpackage3_1 = New frmpackage3_1(mysqlpass, ipconnect, usernamedb, dbname, txtsearch.Text)
                    '  Dim NextForm As main_user = New main_user()
                    NextForm.Show()
                    Me.Close()


                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
            mysql.Close()
        End If


    End Sub
    Public Sub check_box()
        Dim int_fbs As Integer


        If tab4_txt_fbs.Text <> " " Then
            int_fbs = Integer.Parse(tab4_txt_fbs.Text)


            If int_fbs > 111 And int_fbs <= 125 Then
                result_all = result_all + count_result.ToString + ". " + tab4_result_fbs.Text + Environment.NewLine
                count_result = count_result + 1
            ElseIf int_fbs > 125 Then
                result_all = result_all + count_result.ToString + ". " + tab4_result_fbs.Text + Environment.NewLine
                count_result = count_result + 1
            ElseIf int_fbs < 50 Then
                result_all = result_all + count_result.ToString + ". " + tab4_result_fbs.Text + Environment.NewLine
                count_result = count_result + 1
            End If
        End If

        If tab5_txt_bun.Text <> " " Then
            Dim int_bun As Integer
            int_bun = Integer.Parse(tab5_txt_bun.Text)
            If int_bun > 20 Then
                result_all = result_all + count_result.ToString + ". " + tab5_result_bun.Text + Environment.NewLine
                count_result = count_result + 1
            End If
            Dim int_cholesterol As Integer
            int_cholesterol = Integer.Parse(tab5_txt_cholesterol.Text)
            If int_cholesterol > 200 Then
                result_all = result_all + count_result.ToString + ". " + tab5_result_cholesterol.Text + Environment.NewLine
                count_result = count_result + 1
            End If
        End If
        If tab5_txt_creatinine.Text <> " " Then
            Dim int_creatinine As Double
            int_creatinine = Double.Parse(tab5_txt_creatinine.Text)
            If int_creatinine > 1.5 Then
                result_all = result_all + count_result.ToString + ". " + tab5_result_creatinine.Text + Environment.NewLine
                count_result = count_result + 1
            End If
        End If


        If tab5_txt_hdl.Text <> " " Then
            Dim int_hdl As Integer
            int_hdl = Integer.Parse(tab5_txt_hdl.Text)
            If int_hdl < 40 Then
                result_all = result_all + count_result.ToString + ". " + tab5_result_hdl.Text + Environment.NewLine
                count_result = count_result + 1
            End If
        End If
        If tab5_txt_trigyceride.Text <> " " Then
            Dim int_trigyceride As Integer
            int_trigyceride = Integer.Parse(tab5_txt_trigyceride.Text)
            If int_trigyceride > 150 Then
                result_all = result_all + count_result.ToString + ". " + tab5_result_trigyceride.Text + Environment.NewLine
                count_result = count_result + 1
            End If

        End If


        If tab5_txt_uricacid.Text <> " " Then
            Dim int_uricacid As Double
            int_uricacid = Double.Parse(tab5_txt_uricacid.Text)
            If int_uricacid > 8.5 Then
                result_all = result_all + count_result.ToString + ". " + tab5_result_uricacid.Text + Environment.NewLine
                count_result = count_result + 1
            End If
        End If

        If tab6_txt_alkaline.Text <> " " Then
            Dim int_alk As Integer
            int_alk = Integer.Parse(tab6_txt_alkaline.Text)
            If int_alk > 200 Then
                result_all = result_all + count_result.ToString + ". " + tab6_result_alkaline.Text + Environment.NewLine
                count_result = count_result + 1
            End If
        End If

        If tab6_txt_ldl.Text <> " " Then
            Dim int_ldl As Integer
            int_ldl = Integer.Parse(tab6_txt_ldl.Text)
            If int_ldl > 130 Then
                result_all = result_all + count_result.ToString + ". ไขมันในเลือดสูง คำแนะนำ หลีกเลี่ยงหรือลดอาหารประเภทไขมันมาก ได้แก่ อาหารทะเล ไข่แดง เครื่องในสัตว์ เป็นต้น ออกกำลังกายสม่ำเสมอ และตรวจติดตาม หรือตามคำแนะนำของแพทย์" + Environment.NewLine
                count_result = count_result + 1
            End If
        End If



        If tab6_txt_sgot.Text <> " " Then
            Dim int_sgot As Integer
            int_sgot = Integer.Parse(tab6_txt_sgot.Text)

            If int_sgot > 46 And int_sgot < 100 Then
                result_all = result_all + count_result.ToString + ". เอนไซม์ตับสูงกว่าปกติ คำแนะนำ ควรลดอาหารไขมัน หลีกเลี่ยงแอลกอออล(ถ้าดื่ม) ออกกำลังกายสม่ำเสมอ และตรวจติดตาม" + Environment.NewLine
                count_result = count_result + 1
            ElseIf int_sgot > 100 Then
                result_all = result_all + count_result.ToString + ". มีภาวะตับอักเสบ" + Environment.NewLine
                count_result = count_result + 1
            End If
        End If



        If tab6_txt_sgpt.Text <> " " Then
            Dim int_sgpt As Integer
            int_sgpt = Integer.Parse(tab6_txt_sgpt.Text)
            If int_sgpt > 69 Then
                result_all = result_all + count_result.ToString + ". เอนไซม์ตับสูงกว่าปกติ คำแนะนำ ควรลดอาหารไขมัน หลีกเลี่ยงแอลกอออล(ถ้าดื่ม) ออกกำลังกายสม่ำเสมอ และตรวจติดตาม" + Environment.NewLine
                count_result = count_result + 1
            End If

        End If


        check_group = ""
        count_group = 1
        check_form = "0"
        ' ตรวจสอบ result box

        If ComboBox22.Text = "2.ผิดปกติ" And tab1_result_pulse.Text = "กรุณากรอกข้อมูล" Then
            check_group = check_group + count_group.ToString + ". ตรวจสอบ สรุปผล การตรวจสอบชีพจร " + Environment.NewLine
            count_group = count_group + 1
            check_form = "1"
        ElseIf ComboBox22.Text = "2.ผิดปกติ" And tab1_result_pulse.Text <> "กรุณากรอกข้อมูล" Then
            result_all = result_all + count_result.ToString + ". " + tab1_result_pulse.Text + Environment.NewLine
            count_result = count_result + 1
        End If
        If ComboBox3.Text = "2.ผิดปกติ" And tab2_result_redmorphology.Text = "กรุณากรอกข้อมูล" Then
            check_group = check_group + count_group.ToString + ".ตรวจสอบ สรุปผล ผลตรวจเลือด " + Environment.NewLine
            count_group = count_group + 1
            check_form = "1"
        ElseIf ComboBox3.Text = "2.ผิดปกติ" And tab2_result_redmorphology.Text <> "กรุณากรอกข้อมูล" Then
            result_all = result_all + count_result.ToString + ". " + tab2_result_redmorphology.Text + Environment.NewLine
            count_result = count_result + 1
        End If
        If ComboBox21.Text = "2.ผิดปกติ" And tab2_result_platecount.Text = "กรุณากรอกข้อมูล" Then
            check_group = check_group + count_group.ToString + ".ตรวจสอบ สรุปผล Red Plate " + Environment.NewLine
            count_group = count_group + 1
            check_form = "1"
        ElseIf ComboBox21.Text = "2.ผิดปกติ" And tab2_result_platecount.Text <> "กรุณากรอกข้อมูล" Then
            result_all = result_all + count_result.ToString + ". " + tab2_result_platecount.Text + Environment.NewLine
            count_result = count_result + 1
        End If
        If ComboBox1.Text = "2.ผิดปกติ" And tab3_txt_comment.Text = "กรุณากรอกข้อมูล" Then
            check_group = check_group + count_group.ToString + ".ตรวจสอบ สรุปผล วิเคราะห์ปัสสาวะ " + Environment.NewLine
            count_group = count_group + 1
            check_form = "1"
        ElseIf ComboBox1.Text = "2.ผิดปกติ" And tab3_txt_comment.Text <> "กรุณากรอกข้อมูล" Then
            result_all = result_all + count_result.ToString + ". " + tab3_txt_comment.Text + Environment.NewLine
            count_result = count_result + 1
        End If
        If ComboBox8.Text = "2.ผิดปกติ" And tab4_result_phy.Text = "กรุณากรอกข้อมูล" Then
            check_group = check_group + count_group.ToString + ".ตรวจสอบ สรุปผล วิเคราะห์ทั่วไป Physical" + Environment.NewLine
            count_group = count_group + 1
            check_form = "1"
        ElseIf ComboBox8.Text = "2.ผิดปกติ" And tab4_result_phy.Text <> "กรุณากรอกข้อมูล" Then
            result_all = result_all + count_result.ToString + ". " + tab4_result_phy.Text + Environment.NewLine
            count_result = count_result + 1
        End If
        If ComboBox4.Text = "2.ผิดปกติ" And tab4_result_x_ray.Text = "กรุณากรอกข้อมูล" Then
            check_group = check_group + count_group.ToString + ".ตรวจสอบ สรุปผล วิเคราะห์ผล X-Ray" + Environment.NewLine
            count_group = count_group + 1
            check_form = "1"
        ElseIf ComboBox4.Text = "2.ผิดปกติ" And tab4_result_x_ray.Text <> "กรุณากรอกข้อมูล" Then
            result_all = result_all + count_result.ToString + ". " + tab4_result_x_ray.Text + Environment.NewLine
            count_result = count_result + 1
        End If


    End Sub
    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
        tellephone = txt_tell.Text
        name_lastname = txt_name.Text
        doctor_name = dr_name.Text
        savedata()
        ipconnect = "192.0.0.202"
        mysqlpass = "sa"
        usernamedb = "sa"
        dbname = "lab_rajyindee"
        count_result = 1
        result_all = ""

        check_box() ' result box
        red_homology = tab2_txt_redcell.Text
        result_hematology = tab2_result_platecount.Text
        result_phy = tab1_result_pulse.Text
        address = txt_address.Text
        under = txt_aid.Text
        result_physical = tab4_result_phy.Text
        result_xray = tab4_result_x_ray.Text
        result_ekg = tab4_result_ekg.Text

        urine_other = tab3_txt_other.Text

        result_bun = tab5_result_bun.Text
        result_cholesterol = tab5_result_cholesterol.Text
        result_creatinine = tab5_result_creatinine.Text

        result_hdl = tab5_result_hdl.Text
        result_ldl = tab6_result_ldl.Text
        result_sgot = tab6_result_sgot.Text
        result_sgpt = tab6_result_spgt.Text
        result_triglyceride = tab5_result_trigyceride.Text
        result_urine = tab3_txt_comment.Text
        result_uricacid = tab5_result_uricacid.Text

        result_fbs = tab4_result_fbs.Text
        tab2_redcell = tab2_result_redmorphology.Text
        result_alkaline = tab6_result_alkaline.Text





        'tab1
        phy_bloodpressure = tab1_txt_bloodp.Text
        phy_bmi = tab1_txt_bmi.Text
        
        phy_height = tab1_txt_height.Text
        phy_weight = tab1_tab_weight.Text
        phy_pulse = tab1_txt_pulserate.Text







        If check_form = 1 Then
            MsgBox(check_group)
            check_form = "0"
        Else
            Dim NextForm As prnpackage3 = New prnpackage3(mysqlpass, ipconnect, usernamedb, dbname, id_hn, export_id)
            '  Dim NextForm As main_user = New main_user()
            NextForm.Show()
        End If
    End Sub
    Public Sub bmi_cal()
        Dim height As Double
        Dim weight As Double
        Dim result As Double



        If tab1_tab_weight.Text <> " " And tab1_txt_height.Text <> " " Then
            height = tab1_txt_height.Text.Trim
            weight = tab1_tab_weight.Text.Trim
            height = height / 100
            weight = weight / height
            weight = weight / height

            tab1_txt_bmi.Text = Format(weight, "##.##")
        End If
    End Sub
    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        Me.Close()

    End Sub

    Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
        Me.WindowState = FormWindowState.Minimized
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim NextForm As main = New main()
        '  Dim NextForm As main_user = New main_user()
        NextForm.Show()
        Me.Close()
    End Sub
    Private Sub tab1_tab_weight_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles tab1_tab_weight.KeyPress
        If e.KeyChar <> ChrW(Keys.Back) Then
            If (e.KeyChar.ToString >= "A" And e.KeyChar.ToString <= "Z") Or (e.KeyChar.ToString >= "a" And e.KeyChar.ToString <= "z") Then
                e.Handled = True
            Else
                If e.KeyChar = ChrW(Keys.Enter) Then
                    bmi_cal()
                End If
            End If
        End If
    End Sub
    Private Sub tab1_txt_height_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles tab1_txt_height.KeyPress
        If e.KeyChar <> ChrW(Keys.Back) Then
            If (e.KeyChar.ToString >= "A" And e.KeyChar.ToString <= "Z") Or (e.KeyChar.ToString >= "a" And e.KeyChar.ToString <= "z") Then
                e.Handled = True
            Else
                If e.KeyChar = ChrW(Keys.Enter) Then
                    bmi_cal()
                End If
            End If
        End If
    End Sub
    Public Sub savedata()
        mysql = New MySqlConnection
        ' mysql.ConnectionString = "server=" + ipconnect + ";user id=" + usernamedb + ";password=" + mysqlpass + ";database=" + dbname + ";Character Set =utf8;"

        ipconnect = "ryh1"
        mysqlpass = "software"
        usernamedb = "june"
        dbname = "rajyindee_db"

        mysql.ConnectionString = "server=" + ipconnect + ";user id=" + usernamedb + ";password=" + mysqlpass + ";database=" + dbname + ";Character Set =utf8;"
        Try
            mysql.Open()
            '    MsgBox("CONNECTED TO DATABASE")
        Catch ex As Exception
            MsgBox("Can't Connect to database" + ex.Message)
            Me.Close()
        End Try


        Dim mySqlCommand As New MySqlCommand
        Dim mySqlAdaptor As New MySqlDataAdapter
        Dim mySqlReader As MySqlDataReader

        Try

            mySqlCommand.CommandText = "INSERT INTO healthycare_ryh (p_id,p_name,p_sex,p_age,p_tell,p_add,p_aid,p_date,p_height,p_weight,p_bmi,p_pulse,p_blood_pre,blo_gro,blo_rhe,blo_pla,blo_cbc_hb,blo_cbc_hct,blo_cbc_wbc,blo_cbc_n,blo_cbc_e,blo_cbc_b,blo_cbc_l,blo_cbc_m,blo_cbc_a,blo_redcell,uri_col,uri_app,uri_alb,uri_glu,uri_spg,uri_blo,uri_ph,uri_rbe,uri_wbc,uri_epi,uri_other,result_phy,xray,phy_ekg,che_fbs,che_bun,che_cre,che_uri,che_cho,che_tri,che_hdl,che_ldl,che_sgo,che_sgp,che_alk,package_type,date_time) VALUES ('" & txtsearch.Text & "','" & txt_name.Text & "','" & txt_sex.Text & "','" & txt_age.Text & "','" & txt_tell.Text & "','" & txt_address.Text & "','" & txt_aid.Text & "','" & txt_date.Text & "','" & tab1_txt_height.Text & "','" & tab1_tab_weight.Text & "','" & tab1_txt_bmi.Text & "','" & tab1_txt_pulserate.Text & "','" & tab1_txt_bloodp.Text & "','" & tab2_txt_groupblood.Text & "','" & tab2_txt_rh.Text & "','" & tab2_txt_plate.Text & "','" & tab2_txt_hb.Text & "','" & tab2_txt_hct.Text & "','" & tab2_txt_wbc.Text & "','" & tab2_txt_neutrophils.Text & "','" & tab2_txt_eosinophils.Text & "','" & tab2_txt_bashophils.Text & "','" & tab2_txt_lymphocytes.Text & "','" & tab2_txt_monocytes.Text & "','" & tab2_txt_atypical.Text & "','" & tab2_txt_redcell.Text & "','" & tab3_txt_color.Text & "','" & tab3_txt_appearance.Text & "','" & tab3_txt_albumin.Text & "','" & tab3_txt_glucose.Text & "','" & tab3_txt_spgr.Text & "','" & tab3_txt_blood.Text & "','" & tab3_txt_ph.Text & "','" & tab3_txt_rbc.Text & "','" & tab3_txt_wbc.Text & "','" & tab3_txt_epi.Text & "','" & tab3_txt_other.Text & "','" & tab4_result_phy.Text & "','" & tab4_result_x_ray.Text & "','" & tab4_result_ekg.Text & "','" & tab4_txt_fbs.Text & "','" & tab5_txt_bun.Text & "','" & tab5_txt_creatinine.Text & "','" & tab5_txt_uricacid.Text & "','" & tab5_txt_cholesterol.Text & "','" & tab5_txt_trigyceride.Text & "','" & tab5_txt_hdl.Text & "','" & tab6_txt_ldl.Text & "','" & tab6_result_sgot.Text & "','" & tab6_txt_sgpt.Text & "','" & tab6_txt_alkaline.Text & "','P3','" & Date.Now.Date.ToString & "');"
            mySqlCommand.CommandType = CommandType.Text
            mySqlCommand.Connection = mysql
            mySqlCommand.ExecuteNonQuery()

        Catch ex As Exception
            MsgBox(ex.ToString)
            mysql.Close()
            Exit Sub

        End Try



    End Sub
    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged

        check_sub = 0
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        check_sub = 1
    End Sub

    Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint

    End Sub
End Class